package ej5;

import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Vector;

public class Leer {
	
public Leer(){
	
}
public static Vector<Persona> LeerArchivo(File f){
	
	Persona p=new Persona();
	Vector<Persona> personas=new Vector<Persona>();
	
	
	
	try {
		InputStream is=new FileInputStream(f);
		DataInputStream dis=new DataInputStream(is);
		
	while(true){
		try{	
			p.nombre=dis.readUTF();
			p.hs=dis.readInt();
			p.cat=dis.readUTF();
			
			p.calcprecio();
			personas.add(p);
			
	} catch (IOException e) {
		break;
	}
	
	}
	
	dis.close();
	is.close();
	}catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}	
	return personas;
}	


}
